/**
* @author: zhazhjie
* @email: zhazhjie@vip.qq.com
* @date: 2018-11-05 15:33:58
* @version: 1.0
*/

<template>
  <crud-template :config="config"/>
</template>

<script>
import {sysRoleApi} from '@/api/sys/ResourceApi'
import {sysUserApi} from "@/api/sys/SysUserApi";
import {SysUser} from "@/entity/sys/SysUser";

export default {
  name: "sys-user",
  data() {
    return {
      roleList: [],
      config: this.ConfigWrapper.convert({
        showIndex: true,
        $dialog: {
          props: {
            width: '500px'
          }
        },
        $handler: {
          props: {width: '125px', align: 'center'}
        },
        $search: {
          sortList: ['userName', 'state'],
        },
        columns: [
          {
            label: '用户名',
            field: 'userName',
            disabledInEdit: true,
          },
          {
            label: '抖音账号',
            field: 'dyNo',
            value: '-',
          },
          {
            label: '快手账号',
            field: 'ksNo',
            value: '-',
          },
          {
            label: '状态',
            field: 'state',
            type: 'tag',
            value: 1,
            options: [{value: 1, text: "正常"}, {value: 0, text: "禁用"}],
            tagMapping: {
              0: "danger",
              1: "success"
            },
            $dialog: {
              type: "radio",
              value: 1,
            },
            $search: {
              type: "select",
              props: {
                clearable: true
              }
            }
          },
          {
            label: '创建时间',
            field: 'createTime',
            value: '-',
            $dialog: {
              hide: true
            },
          }
        ],
        handlerList: [
          {
            label: '编辑',
            icon: 'el-icon-edit'
          },
          {
            label: '删除',
            icon: 'el-icon-delete',
            click: row => {
              this.$crudTmp.handleDelete(row, row.userName);
            }
          }
        ],
        rules: {
          userName: [
            {required: true, message: '请输入用户名', trigger: 'blur'}
          ],
        },
      }, new SysUser()),
    }
  },
  methods: {
    getRoleList() {
      sysRoleApi.listAll().then(res => {
        this.roleList = res.data;
      });
    },
  },
  computed: {},
  mounted() {
    this.$crudTmp.injectApi(sysUserApi);
  }
}
</script>

<style scoped>

</style>
